//
//  PatientBaseInfoCell.m
//  Doctor
//
//  Created by 阳光 on 16/9/7.
//  Copyright © 2016年 阳光. All rights reserved.
//  病例患者基本信息

#import "PatientBaseInfoCell.h"

@interface PatientBaseInfoCell ()

// 出生年份
@property(nonatomic,strong)UILabel *birthYearLabel;

@property(nonatomic,strong)UIView *birthYearLine;

// 身高
@property(nonatomic,strong)UILabel *heightLabel;

@property(nonatomic,strong)UIView *heightLine;

// 体重
@property(nonatomic,strong)UILabel *weightLabel;

@property(nonatomic,strong)UIView *weightLine;

// 结婚状况
@property(nonatomic,strong)UILabel *isMarryLabel;

@property(nonatomic,strong)UIView *isMarryLine;

// 结婚时间
@property(nonatomic,strong)UILabel *marryYearLabel;

@property(nonatomic,strong)UIView *marryYearLine;

// 配偶姓名
@property(nonatomic,strong)UILabel *spouseNameLabel;

@property(nonatomic,strong)UIView *spouseNameLine;

// 配偶出生年份
@property(nonatomic,strong)UILabel *spouseNameBirthYearLabel;

@property(nonatomic,strong)UIView *spouseNameBirthYearLine;

@end


@implementation PatientBaseInfoCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor=WhiteColor;
        
        self.birthYearLabel.font=Font_Number(16);
        self.birthYearLine.hidden=NO;
        
        self.heightLabel.font=Font_Number(16);
         self.heightLine.hidden=NO;
        
        self.weightLabel.font=Font_Number(16);
        self.weightLine.hidden=NO;
        
        self.isMarryLabel.font=Font_Number(16);
        self.isMarryLine.hidden=NO;
        
        self.marryYearLabel.font=Font_Number(16);
        self.marryYearLine.hidden=NO;
        
        self.spouseNameLabel.font=Font_Number(16);
        self.spouseNameLine.hidden=NO;
        
        self.spouseNameBirthYearLabel.font=Font_Number(16);
        self.spouseNameBirthYearLine.hidden=NO;
        
    };
    return self;
}

// birthYearLabel
-(UILabel *)birthYearLabel
{
    if (!_birthYearLabel) {
        _birthYearLabel=[self getLabelWithText:@"1993年02月30日" font:Font_Number(16) textColor:Color333333 textAlignment:NSTextAlignmentRight lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:_birthYearLabel];
        
        UILabel *leftBirthYearLabel=[self getLabelWithText:NSLocalizedString(@"Birthday", nil) font:Font_Number(16) textColor:Color666666 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:leftBirthYearLabel];
        
        [leftBirthYearLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.mas_equalTo(kmargin);
        }];
        
        [_birthYearLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(kmargin);
            make.right.mas_equalTo(-kmargin);
        }];
    }
    return _birthYearLabel;
}

-(UIView *)birthYearLine
{
    if (!_birthYearLine) {
        _birthYearLine=[UIView new];
        _birthYearLine.backgroundColor=MAIN_BACK_COLOR;
        [self.contentView addSubview:_birthYearLine];
        [_birthYearLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.birthYearLabel.mas_bottom).offset(kmargin);
            make.left.mas_equalTo(kmargin);
            make.right.mas_equalTo(-kmargin);
            make.height.mas_equalTo(1);
        }];
    }
    return _birthYearLine;
}

// heightLabel
-(UILabel *)heightLabel
{
    if (!_heightLabel) {
        _heightLabel=[self getLabelWithText:@"156-160cm" font:Font_Number(16) textColor:Color333333 textAlignment:NSTextAlignmentRight lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:_heightLabel];
        
        UILabel *leftHeightLabel=[self getLabelWithText:NSLocalizedString(@"Height", nil) font:Font_Number(16) textColor:Color666666 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:leftHeightLabel];
        
        [leftHeightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kmargin);
            make.top.mas_equalTo(self.birthYearLine.mas_bottom).offset(kmargin);
        }];
        
        [_heightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.birthYearLine.mas_bottom).offset(kmargin);
            make.right.mas_equalTo(-kmargin);
        }];
    }
    return _heightLabel;
}

-(UIView *)heightLine
{
    if (!_heightLine) {
        _heightLine=[UIView new];
        _heightLine.backgroundColor=MAIN_BACK_COLOR;
        [self.contentView addSubview:_heightLine];
        [_heightLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.heightLabel.mas_bottom).offset(kmargin);
            make.left.mas_equalTo(kmargin);
            make.right.mas_equalTo(-kmargin);
            make.height.mas_equalTo(1);
        }];
    }
    return _heightLine;
}

// weightLabel
-(UILabel *)weightLabel
{
    if (!_weightLabel) {
        _weightLabel=[self getLabelWithText:@"51-55kg" font:Font_Number(16) textColor:Color333333 textAlignment:NSTextAlignmentRight lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:_weightLabel];
        
        UILabel *leftWeightLabel=[self getLabelWithText:NSLocalizedString(@"Weight", nil) font:Font_Number(16) textColor:Color666666 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:leftWeightLabel];
        
        [leftWeightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kmargin);
            make.top.mas_equalTo(self.heightLine.mas_bottom).offset(kmargin);
        }];
        
        [_weightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.heightLine.mas_bottom).offset(kmargin);
            make.right.mas_equalTo(-kmargin);
        }];
    }
    return _weightLabel;
}

-(UIView *)weightLine
{
    if (!_weightLine) {
        _weightLine=[UIView new];
        _weightLine.backgroundColor=MAIN_BACK_COLOR;
        [self.contentView addSubview:_weightLine];
        [_weightLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.weightLabel.mas_bottom).offset(kmargin);
            make.left.mas_equalTo(kmargin);
            make.right.mas_equalTo(-kmargin);
            make.height.mas_equalTo(1);
        }];
    }
    return _weightLine;
}

// isMarryLabel
-(UILabel *)isMarryLabel
{
    if (!_isMarryLabel) {
        _isMarryLabel=[self getLabelWithText:@"已婚" font:Font_Number(16) textColor:Color333333 textAlignment:NSTextAlignmentRight lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:_isMarryLabel];
        
        UILabel *leftIsMarryLabel=[self getLabelWithText:NSLocalizedString(@"Marital status", nil) font:Font_Number(16) textColor:Color666666 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:leftIsMarryLabel];
        
        [leftIsMarryLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kmargin);
            make.top.mas_equalTo(self.weightLine.mas_bottom).offset(kmargin);
        }];
        
        [_isMarryLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.weightLine.mas_bottom).offset(kmargin);
            make.right.mas_equalTo(-kmargin);
        }];
    }
    return _isMarryLabel;
}

-(UIView *)isMarryLine
{
    if (!_isMarryLine) {
        _isMarryLine=[UIView new];
        _isMarryLine.backgroundColor=MAIN_BACK_COLOR;
        [self.contentView addSubview:_isMarryLine];
        [_isMarryLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.isMarryLabel.mas_bottom).offset(kmargin);
            make.left.mas_equalTo(kmargin);
            make.right.mas_equalTo(-kmargin);
            make.height.mas_equalTo(1);
        }];
    }
    return _isMarryLine;
}

// marryYearLabel
-(UILabel *)marryYearLabel
{
    if (!_marryYearLabel) {
        _marryYearLabel=[self getLabelWithText:@"3年" font:Font_Number(16) textColor:Color333333 textAlignment:NSTextAlignmentRight lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:_marryYearLabel];
        
        UILabel *leftMarryYearLabel=[self getLabelWithText:NSLocalizedString(@"Married years", nil) font:Font_Number(16) textColor:Color666666 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:leftMarryYearLabel];
        
        [leftMarryYearLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kmargin);
            make.top.mas_equalTo(self.isMarryLine.mas_bottom).offset(kmargin);
        }];
        
        [_marryYearLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.isMarryLine.mas_bottom).offset(kmargin);
            make.right.mas_equalTo(-kmargin);
        }];
    }
    return _marryYearLabel;
}

-(UIView *)marryYearLine
{
    if (!_marryYearLine) {
        _marryYearLine=[UIView new];
        _marryYearLine.backgroundColor=MAIN_BACK_COLOR;
        [self.contentView addSubview:_marryYearLine];
        [_marryYearLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.marryYearLabel.mas_bottom).offset(kmargin);
            make.left.mas_equalTo(kmargin);
            make.right.mas_equalTo(-kmargin);
            make.height.mas_equalTo(1);
        }];
    }
    return _marryYearLine;
}

// spouseNameLabel
-(UILabel *)spouseNameLabel
{
    if (!_spouseNameLabel) {
        _spouseNameLabel=[self getLabelWithText:@"王五" font:Font_Number(16) textColor:Color333333 textAlignment:NSTextAlignmentRight lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:_spouseNameLabel];
        
        UILabel *leftSpouseNameLabel=[self getLabelWithText:NSLocalizedString(@"Spouse's name", nil) font:Font_Number(16) textColor:Color666666 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:leftSpouseNameLabel];
        
        [leftSpouseNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kmargin);
            make.top.mas_equalTo(self.marryYearLine.mas_bottom).offset(kmargin);
        }];
        
        [_spouseNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.marryYearLine.mas_bottom).offset(kmargin);
            make.right.mas_equalTo(-kmargin);
        }];
    }
    return _spouseNameLabel;
}

-(UIView *)spouseNameLine
{
    if (!_spouseNameLine) {
        _spouseNameLine=[UIView new];
        _spouseNameLine.backgroundColor=MAIN_BACK_COLOR;
        [self.contentView addSubview:_spouseNameLine];
        [_spouseNameLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.spouseNameLabel.mas_bottom).offset(kmargin);
            make.left.mas_equalTo(kmargin);
            make.right.mas_equalTo(-kmargin);
            make.height.mas_equalTo(1);
        }];
    }
    return _spouseNameLine;
}

// spouseNameBirthYearLabel
-(UILabel *)spouseNameBirthYearLabel
{
    if (!_spouseNameBirthYearLabel) {
        _spouseNameBirthYearLabel=[self getLabelWithText:@"1987年09月17日" font:Font_Number(16) textColor:Color333333 textAlignment:NSTextAlignmentRight lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:_spouseNameBirthYearLabel];
        
        UILabel *leftSpouseNameBirthYearLabel=[self getLabelWithText:NSLocalizedString(@"Spouse's birthday", nil) font:Font_Number(16) textColor:Color666666 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:leftSpouseNameBirthYearLabel];
        
        [leftSpouseNameBirthYearLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kmargin);
            make.top.mas_equalTo(self.spouseNameLine.mas_bottom).offset(kmargin);
        }];
        
        [_spouseNameBirthYearLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.spouseNameLine.mas_bottom).offset(kmargin);
            make.right.mas_equalTo(-kmargin);
        }];
    }
    return _spouseNameBirthYearLabel;
}

-(void)setPatientInfoDic:(NSDictionary *)patientInfoDic
{
    _patientInfoDic=patientInfoDic;
    
    _birthYearLabel.text=patientInfoDic[@"birthday"];
    
    _heightLabel.text=[NSString stringWithFormat:@"%@cm",patientInfoDic[@"height"]];
   
    _weightLabel.text=[NSString stringWithFormat:@"%@kg",patientInfoDic[@"weight"]];
    
    _isMarryLabel.text=patientInfoDic[@"marital"];
    
    _marryYearLabel.text=[NSString stringWithFormat:@"%@年",patientInfoDic[@"marital_year"]];
    
    _spouseNameLabel.text=patientInfoDic[@"spouse_name"];
    
    _spouseNameBirthYearLabel.text=patientInfoDic[@"spousebirthday"];
    
}

@end
